<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>活动</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>
<form class="layui-form"  action="" lay-filter="edit">
    <input type="hidden" name="a_id">
    <div class="layui-form-item">
        <label class="layui-form-label">活动主题：</label>
        <div class="layui-input-inline">
            <input type="text" name="a_subject" lay-verify="required" placeholder="请输入活动主题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">活动内容：</label>
        <div class="layui-input-inline">
            <input type="text" name="a_content" lay-verify="required" placeholder="请输入活动内容" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">活动地点：</label>
        <div class="layui-input-inline">
            <input type="text" name="a_site" lay-verify="required" placeholder="请输入活动地点" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">活动经费：</label>
        <div class="layui-input-inline">
            <input type="text" name="a_cost" lay-verify="required" placeholder="请输入活动经费" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">活动组织人：</label>
        <div class="layui-input-inline">
            <input type="text" name="a_organizer" lay-verify="required" placeholder="请输入活动组织人" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">活动时间：</label>
        <div class="layui-input-inline">
            <input type="text" name="a_taketime" id="a_taketime" lay-verify="a_taketime" placeholder="请输入活动时间" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script src="/static/js/system.js"></script>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','layer'], function(){
        var form = layui.form,
            laydate = layui.laydate;
        laydate.render({
            elem: '#a_taketime'
        });
        $.ajax({
            url:'/ActivityServlet?action=showById',
            type:"post",
            dataType:"json",
            data:{"a_id":getQueryString("a_id")},
            success:function (da) {
                console.log(da)
                if (da.code == 200) {
                    //form.val("edit", da.date);
                    form.val("edit", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                        "a_id": da.date.a_id
                        ,"a_subject": da.date.a_subject
                        ,"a_content": da.date.a_content
                        ,"a_site": da.date.a_site
                        ,"a_cost": da.date.a_cost
                        ,"a_organizer": da.date.a_organizer
                        ,"a_taketime": layui.util.toDateString(da.date.a_taketime, 'yyyy-MM-dd')
                    });
                } else {
                    parent.layer.msg("详情查询失败！");
                }
            }
        });
        //监听提交 15039939677
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("edit");
            $.ajax({
                url:'/ActivityServlet?action=update',
                type:"post",
                dataType:"json",
                data:data1,
                success:function (da) {
                    if (da.code == 200) {
                        layer.alert("修改成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                        });
                    } else {
                        layer.msg("修改失败！");
                    }
                }
            });
            return false;
        });
    });
</script>
</html>